import Vue from 'vue'
import App from './App.vue'
import ElementUI from 'element-ui';
import VueRouter from "vue-router";
import store from "./store"
import router from "./router"
import VueContextMenu from 'vue-contextmenu'
import axios from 'axios';
import VueAxios from 'vue-axios';
import mock from "../mock/index";
import VueCoreVideoPlayer from 'vue-core-video-player'
import 'element-ui/lib/theme-chalk/index.css';
import PATH_ElOverlayAutoClose from "@/utils/el-overlay-auto-close.js"

// 引入iconfont的css
// import "@/assets/iconfont/iconfont.css"
// import scrollTimerDirective from './directors/scrollTimerDirective';
import { BASE_URL, UPLOAD_PATH } from '@/utils/constant'
// Vue.directive('scroll-timer', scrollTimerDirective);
axios.interceptors.request.use(function (config) {
  // 如果是上传文件的请求，使用multipart/form-data作为content-type
  // console.log(config.url)
  if (config.url === UPLOAD_PATH) {
    config.headers['Content-Type'] = 'multipart/form-data';
  } else {
    // 其他请求使用application/json;charset=utf-8作为content-type
    config.headers['Content-Type'] = 'application/json;charset=utf-8';
  }
  return config;
});
Vue.config.productionTip = false

Vue.use(ElementUI);
Vue.use(VueRouter);
Vue.use(mock)

Vue.use(VueContextMenu)
Vue.use(VueAxios, axios);
Vue.use(VueCoreVideoPlayer, {
  lang: 'zh-CN'
})
Vue.use(PATH_ElOverlayAutoClose)


// 请求前缀
// 后端
Vue.prototype.$reqPrefix = BASE_URL
// Vue.prototype.$reqPrefix = "http://192.168.1.124:8088/home/home"
// Vue.prototype.$reqPrefix = "http://192.168.101.88:8088/home/home"
// 前端
// Vue.prototype.$reqPrefix = ""

// 负责弹窗显示某个操作结果的
/**
 * 
 * @param {*} code 状态码
 * @param {*} sucMsg 成功的显示消息
 * @param {*} errMsg 失败的显示消息
 */
Vue.prototype.$codeJudge = function codeJudge(code, sucMsg = "操作成功", errMsg = "操作失败") {
  if (code == 200) {
    this.$message({
      message: sucMsg,
      type: "success",
    });
  } else {
    this.$message.error(errMsg);
  }
}

new Vue({
  render: h => h(App),
  router,
  store
}).$mount('#app')
